package com.mzj.saas.mservice.auth.controller;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.mzj.saas.commons.HttpUtils;
import com.mzj.saas.mservice.auth.vo.FaceResponseVo;
import com.mzj.saas.mservice.auth.vo.ResponseVo;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class test {
  /*  public static void main(String[] args) {
        String host = "https://selfiev2.market.alicloudapi.com";
        String path = "/face/verify_selfie_idnumber";
        String method = "POST";
        String appcode = "c7ea3c07756340848ed57e19b55adbda";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        //根据API的要求，定义相对应的Content-Type
        headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
        Map<String, String> querys = new HashMap<String, String>();
        Map<String, String> bodys = new HashMap<String, String>();
        bodys.put("id_number", "44528119980418137");
        // bodys.put("image", "image");
        bodys.put("image_url", "http://xj-saas-images.oss-cn-qingdao.aliyuncs.com/ad/202301031672739191065.jpg");
        bodys.put("name", "陈海龙");


        try {
            */

    /**
     * 重要提示如下:
     * HttpUtils请从
     * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
     * 下载
     * <p>
     * 相应的依赖请参照
     * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
     *//*
            HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
            String s = EntityUtils.toString(response.getEntity());
            FaceResponseVo voS = JSONUtil.toBean(s, FaceResponseVo.class);
            Integer resultCode = voS.getResultCode();
            System.out.println("resultCode = " + resultCode);
            String resultMessage = voS.getResultMessage();
            System.out.println("resultMessage = " + resultMessage);
            String status = voS.getStatus();
            System.out.println("status = " + status);
            // System.out.println(response.toString());
            //获取response的body
            // System.out.println(EntityUtils.toString(response.getEntity()));
            // 系统判断为同一人  1001
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/
    public static void main(String[] args) throws IOException {
        String url = "https://eid.shumaidata.com/eid/check";
        String appCode = "ed3c5fd3ff7b4621a9bc18a4960f81aa";

        Map<String, Object> params = new HashMap<>();
        params.put("idcard", "445281199804181377");
        params.put("name", "陈海龙");
        String result = HttpRequest.post(url)
                .header("Authorization", "APPCODE " + appCode)// 头信息，多个头信息多次调用此方法即可
                .form(params)
                .timeout(20000)// 超时，毫秒
                .execute().body();
        System.out.println(result);
    }

}
